﻿DELIMITER //

--
--
DROP PROCEDURE IF EXISTS spZeusPackageReceive
//

-- HU - Rakomány info
-- EN - Package information
--
--
CREATE PROCEDURE spZeusPackageReceive 
  (_AccessToken INTEGER, _SupplyID INTEGER, _Code VARCHAR(20), _Ean VARCHAR(128), _Quantity DECIMAL(18,6))
BEGIN
  DECLARE _Rows INTEGER;
  DECLARE _UserID INTEGER;
  DECLARE _Lang VARCHAR(10);

  --
  --
  CALL spAccessTokenCheck(_AccessToken, _UserID, _Lang);

  
  IF (IFNULL(_Quantity, 0) <= 0) THEN

    IF (_Lang = 'HU') THEN
      SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = N'Mennyiség nem lehet 0 vagy negatív !';
    END IF;

    IF (_Lang = 'EN') THEN
      SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = N'Quantity could not been equal or less than Zero !';
    END IF;

    IF (_Lang = 'DE') THEN
      SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = N'Menge kann nicht negativ sein !';
    END IF;
  END IF;


  CALL spZeusPackageAdd(_Lang, _SupplyID, _Code, _Ean, _Quantity);


  -- HU - Visszaadja ennek a Rakománynak az adatait
  -- EN - Get the package details
  --
  SELECT Code, ArticleCode, ArticleName, Expired, LocationCode, Quantity, UnitCode, '' Notes
    FROM ZeusPackage
   WHERE Code = _Code;
END
//
